
<template>
  <div class="hello">
    <div class="row" id="pdfDom" style="padding-top: 55px;background-color:#fff;">
      <div>
        <img src="@/assets/logo.png" alt>
      </div>
      <div>//给自己需要导出的ui部分.定义id为"pdfDom".此部分将就是pdf显示的部分</div>
    </div>
    <button type="button" class="btn btn-primary" v-on:click="getPdf()">导出PDF</button>
    <div id="printTest" ref="print">
      <div id="myChart" :style="{width: '300px', height: '300px'}"></div>
      <div>
        <img src="@/assets/logo.png" alt>
      </div>
      <p>锄禾日当午</p>

      <p>汗滴禾下土</p>

      <p>谁知盘中餐</p>

      <p>粒粒皆辛苦</p>
    </div>

    <button @click="pri">打印</button>

    <demo></demo>
  </div>
</template>

<script>

import demo from '@/components/demo'
require('@/utils/html2canvas')
// require('@/utils/jsPdf')
export default {
  components:{demo},
  name: "HelloWorld",
  data() {
    return {
      msg: "Welcome to Your Vue.js App",
      htmlTitle: "页面导出PDF文件名"
    };
  },
  mounted(){
    this.drawLine();
  },
  methods: {
    pri(){
      this.$print(this.$refs.print) // 使用
    },
     drawLine(){
        // 基于准备好的dom，初始化echarts实例
        let myChart = this.$echarts.init(document.getElementById('myChart'))
        // 绘制图表
        myChart.setOption({
            title: { text: '在Vue中使用echarts' },
            tooltip: {},
            xAxis: {
                data: ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"]
            },
            yAxis: {},
            series: [{
                name: '销量',
                type: 'bar',
                data: [5, 20, 36, 10, 10, 20]
            }]
        });
    }
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss" type="text/css">
h1,
h2 {
  font-weight: normal;
  color: red;
}
ul {
  list-style-type: none;
  padding: 0;
  li {
    display: inline-block;
    margin: 0 10px;
    color: red;
  }
}
// a {
//   color: #42b983;
// }
</style>
